package com.hy.controller;

import com.hy.common.Result;
import com.hy.service.SchoolRankingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/app/school")
public class SchoolRankingController {

    @Autowired
    private SchoolRankingService schoolRankingService;

    /**
     * 学员按积分、等级(消费金额)排名，支持关键词查询
     * @param keyword 关键词（会员号、姓名、手机号）
     * @param pageNum 页码，默认1
     * @param pageSize 每页数量，默认10
     * @return Result对象，包含排名数据
     */
    @GetMapping("/ranking")
    public Result getSchoolRanking(
            @RequestParam(required = false) String keyword,
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize) {
        return schoolRankingService.getSchoolRanking(keyword, pageNum, pageSize);
    }

}
